#!/usr/bin/env bash

container=$1
if [ "$container" != "" ]; then
    echo $container > last_commit.txt
    docker exec -ti $container bash
    exit 0
elif [ -f last_commit.txt ]; then
    container=`cat last_commit.txt`
else
    echo "ContainerId"
    exit -1
fi

if [ "$container" = "" ]; then
    echo "last_commit.txt is empty"
    exit -1
fi

docker exec -ti $container bash